﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ShellAnywhere.Model
{
	[XmlRoot]
	public class Param : IParam
	{
		#region ctors
		public Param() : this("") { }
		public Param(string name)
		{
			Name = name;
		}
		#endregion ctors

		#region props
		[XmlAttribute]
		public virtual string Name { get; set; }
		#endregion props

		#region methods
		public virtual char CharAt(int dot)
		{
			char charAtDot = '\0';
			if (0 <= dot && dot < Name.Length)
				charAtDot = Name[dot];
			return charAtDot;
		}
		public virtual string Matched(int dot)
		{
			string matched = "";
			if (0 <= dot && dot <= Name.Length)
				matched = Name.Substring(0, dot);
			return matched;
		}
		public virtual string Unmatched(int dot)
		{
			string unmatched = "";
			if (0 <= dot && dot <= Name.Length)
				unmatched = Name.Substring(dot, Name.Length - dot);
			return unmatched;
		}
		public virtual bool IsMatched(int dot)
		{
			return CharAt(dot) == '\0';
		}
		public virtual bool IsLastDot(int dot)
		{
			return (Name.Length - 1) - dot <= 0;
		}
		public override string ToString()
		{
			return Name;
		}
		#endregion methods

		#region fields
		#endregion fields
	}
}
